#ifndef FIELD_HH
#define FIELD_HH

#include <QWidget>
#include "tetra.hh"

class Field : public QWidget {
    Q_OBJECT
public:
    Field(int, int, uint, uint, float, QWidget * parent = 0);
    ~Field();

signals:

public slots:
    void moveTetraDown();
    void nextLevel();

protected:
    char ** field;
    uint columnsCount;
    uint rowsCount;
    float cubeSize;
    QTimer *tetraMoveTimer;

    void keyPressEvent(QKeyEvent*);
    void paintEvent(QPaintEvent *);
    bool insertTetra();
    bool testTetra();
    void deleteTetra();
    bool isFill(uint);
    size_t deleteFillingLine();
    int& ColumnNum() {return columnNum;}
    const int& ColumnNum() const {return columnNum;}
    int& RowNum() {return rowNum;}
    const int& RowNum() const {return rowNum;}

private:
    Tetra *tetra;
    int columnNum;
    int rowNum;

    uint level;
    uint score;
    uint lines;

    uint levelup_score;
    uint one_line_score;
    uint two_line_score;
    uint three_line_score;
    uint four_line_score;
    uint tetra_move_timeout;

    void drawQuad(QPointF, QColor, QColor);
  //  void drawTetra();
    void drawField();
    void drawString(uint, uint, QFont, QString);

    uint getRandomValue();
    void gamePause();
};

#endif // FIELD_HH
